<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/22 0022
 * Time: 10:10
 */

namespace app\admin\controller;


use think\Controller;
use think\Config;
use think\Loader;
use think\Db;

class StatementController extends BaseController
{
    /*
     * 会员分析
     */
    public function user_analysis(){

        if (request()->isAjax()){
            $data=Db::name("user")->field("count(id) as num,user_system as name")->group("user_system")->select();
            $result["code"]=1;
            $result["data"]=$data;
            return json($result);
        }
        return $this->fetch("user_analysis");

    }
    /*
     * 管理员分析
     */
    public function admin_analysis(){

        if (request()->isAjax()){
            $bar_top=Db::name("login_admin")
                ->alias('la')
                ->join("admin a"," a.id=la.admin_id","left")
                ->field("count(la.admin_id) as num,a.names as name")
                ->group("la.admin_id")
                ->select();
            $bar_bottom_left=Db::name("login_admin")
                ->alias('la')
                ->field("count(la.admin_id) as num,la.browser as name")
                ->group("la.browser")
                ->select();
            $bar_bottom_right=Db::name("login_admin")
                ->alias('la')
                ->field("count(la.admin_id) as num,la.type_os as name")
                ->group("la.type_os")
                ->select();
            $result["code"]=1;
            $result["bar_top"]=$bar_top;
            $result["bar_bottom_left"]=$bar_bottom_left;
            $result["bar_bottom_right"]=$bar_bottom_right;
            return json($result);
        }
        return $this->fetch("admin_analysis");

    }

}